package com.engr.lyx.base.biz.controller;

import com.engr.lyx.base.biz.service.UserService;
import com.engr.lyx.base.client.api.UserRemoteService;
import com.engr.lyx.base.client.req.UserReq;
import com.engr.lyx.base.client.vo.UserVO;
import com.engr.lyx.common.base.ResultBody;
import com.engr.lyx.common.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: blog
 * @desc:
 * @author: lyx
 * @date: 2019-01-25 13:52
 **/
@RestController
@RequestMapping(value = "/user", name = "用户相关接口")
public class UserController implements UserRemoteService {

    @Autowired
    private UserService userService;

    @Override
    @GetMapping(value = "/login", name = "用户登录")
    public ResultBody<UserVO> login(@RequestParam(value = "username") String username) {

        UserVO userVO = userService.login(username);
        return ResultUtils.success(userVO);
    }

    @PostMapping(value = "/register", name = "注册接口")
    public ResultBody<UserVO> register(@RequestBody UserReq userReq) {

        return ResultUtils.success(userService.register(userReq));
    }

}
